Skip to content

Add a lint to warn about un-necessary .into_iter() - #1250

Merged
mcarton merged 3 commits into
rust-lang:masterfrom
elliottneilclark:explicit_into_iter
Oct 1, 2016
Merged

Add a lint to warn about un-necessary .into_iter()#1250
mcarton merged 3 commits into
rust-lang:masterfrom
elliottneilclark:explicit_into_iter

Conversation

@elliottneilclark

Copy link
Copy Markdown
Contributor

This should close #1094.

Comment thread clippy_lints/src/loops.rs Outdated
object,
method_name));
}
} else if method_name.as_str() == "into_iter" && match_trait_method(cx, arg, &paths::I) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be INTO_ITERATOR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah miss commit.

}

#[deny(needless_range_loop, explicit_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop)]
#[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually just do #[deny(clippy)]. I wonder why this file does not use that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know for sure. Let me clean that up in a separate pr.

Comment thread tests/compile-fail/for_loop.rs Outdated
for _v in vec.iter_mut() { } //~ERROR it is more idiomatic to loop over `&mut vec`


let mut _out_vec = vec![1,2,3];

@mcarton mcarton Oct 1, 2016

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a leading _ here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed. Let me remove it.

@mcarton
mcarton merged commit 8babb2d into rust-lang:master Oct 1, 2016
@mcarton

mcarton commented Oct 1, 2016

Copy link
Copy Markdown
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lint unnecessary .into_iter()

2 participants